Demands of the nonvolatile storage device including a nonvolatile main storage memory capable of rewriting widely spread mainly in the semiconductor memory card. Such semiconductor memory cards include various types, and as one of them, there is a SD memory card (registered trademark). This SD memory card includes a flash memory as a nonvolatile main storage memory, and has a memory controller for controlling it. The memory controller is configured to perform read-write control on the flash memory in response to read-write instructions from an access device such as a digital still camera, a body of a PC (personal computer).
Now consider a case where such the SD memory card is attached to the access device of the personal computer etc., and the personal computer assumes it as a removable disk, controls it with a FAT file system, and thereby accesses the data.
Originally, the FAT file system is a system whereby data reading and writing are instructed in units of clusters which are minimum write units of data using a file allocation table (FAT) when recording a file and data in a recording device.
Among recording devices, recording devices of a magnetic recording type, such as a hard disk or a flexible disk, are characterized in that a cluster size and an erase size are identical, realizing a mechanism which enables erasing and overwriting of data for every specified cluster. Because of this, the FAT file system is a file management system that is very convenient for the recording devices of the magnetic recording type.
On the other hand, in flash memories of a NAND type and of an AND type that constitute the SD memory card, conventionally the cluster size and the erase size (a size of a physical block) are identical, and, for example, 16 k bytes. Therefore, even when data in the SD memory card is managed by using the FAT file system, no problem takes place because it does not differ largely from the recording devices of the magnetic recording type.
In recent years, however, with a need for enlarging a capacity of the flash memory, a flash memory whose physical block size, i.e., the erase size is larger than or equal to 128 k bytes becomes the mainstream. As is well known, such large-capacity flash memory is a device characterized in that the erase size is larger than the cluster size (for example, 16 k bytes) and an overwriting in units of clusters is impossible.
Assume that data of one cluster is rewritten in the SD memory card composed of such large-capacity flash memory. Particularly, assumed is a case where “data needing to be rewritten” and “non-rewritten data not needing to be rewritten” exist in a one physical block of the SD memory card.
In this case, “data rewriting of only one cluster in the physical block” that is required by the FAT file system side cannot be done simply. Because of this, the SD memory card receiving a rewrite instruction temporarily saves the non-rewritten data in another physical block once, and then the new data is written in the other physical block in which the non-rewritten data has been saved.
Such a technique of rewrite processing is disclosed in, for example, Patent document 1.
The nonvolatile storage device disclosed in this document employs a method whereby, when a part in a physical block storing old data is rewritten with new data, the non-rewritten data is copied (saved) in another physical block from the physical block. Such a technique of rewriting will be referred to as a “rewriting technique on the premise of saving data” in the present specification.
An outline procedure of this “rewriting technique on the premise of saving data” is as follows. Usually, in the physical block on the flash memory, sectors are arranged in a logical order, namely sequentially from a lower address side (from a small address value) of the physical block so that logical sector numbers align 0, 1, . . . . Data writing by the rewriting technique on the premise of saving data is performed as follows:
(i) a step for receiving a logical address specified by an access device;
(ii) a step for converting the logical address into a physical address on the main storage memory;
(iii) a step for, when only a part of the data stored in the physical block is rewritten with new data, copying the old data that is not changed (non-rewritten data) in a already erased physical block that exists separately from the physical block;
(iv) a step for writing new data in the already erased physical block in which the old data was copied;
(v) a step for allocating the physical block in which the old data has been recorded to an unused physical block; and
(vi) a step for erasing the contents of the old physical block.
As is clear from the above explanation, since the “rewriting technique on the premise of saving data” is such that un-rewritten data is temporarily saved in another physical block although it is the rewriting of one cluster, subsequently new data is written in the physical block, and the physical block previously being used is erased, the technique is complicated and time-consuming processing.
As a technique whereby a counter measure is devised to such a problem, Patent document 2 discloses the technique, for example.
Flash memory that employs this technique is free from a restriction where a sector arrangement order in the physical block should be a logical order and is so configured that the data may be written in a received order of write commands from the lower order page of the physical block. Moreover, a recording state is controlled by indicating whether valid data is written in each page in which each sector is written or whether the data is invalid because of old data. Hereafter, this management technique will be referred to as an “additional writing type rewriting technique”.
By the additional writing type rewriting, since no saving processing of the data takes place each time the access device issues a command of the data writing, writing itself is performed at a relatively high speed, however, a garbage correction is required at a certain timing. The garbage collection is processing where only valid sectors are selected from the predetermined block and are written in another block that is already erased, and the block that becomes invalid is erased.
Patent documents 1: Japanese Unexamined Patent Publication No. 2003-263894
Patent documents 2: Japanese Unexamined Patent Publication No. Hei 5-27924